package cn.com.sbell.vss.csg.vap;

import org.dom4j.Element;

import cn.com.sbell.vss.VssConstants;
import cn.com.sbell.vss.VssException;
import cn.com.sbell.vss.csg.vap.bean.NTPInfo;
import cn.com.sbell.vss.csg.vsclient.VsClient;
import cn.com.sbell.vss.csg.vsclient.util.BeanValidator;
import cn.com.sbell.vss.csg.vsclient.util.PropertiesHolder;

public class SetVsNTP extends ProtectedVsCommander {

	protected Element executeCommand(VsClient vsClient,
			PropertiesHolder holder, Element root) {
		NTPInfo ntpInfo = (NTPInfo) holder.populate(new NTPInfo());
		BeanValidator.validateNotNull(ntpInfo, new String[] { "ntpEnable",
				"ntpHost", "timeZone" });
		if (!vsClient.setNTP(ntpInfo)) {
			throw new VssException(VssConstants.CODE_SET_NTP_FAILED);
		}
		return root;
	}

}
